
/*
Output: Figure 1. Program Engagement and Enrollment Rates
*/

run "/Users/holyfantastic/Dropbox/Forest/Paper/Nature/FinalDocuments/Code/000declare_path" // change to your local path

use "ParcelLevelDataSept282023_VerNov82024_R1.dta" , clear

*keep a snapshot of 2022
keep if year == 2022

*Requiring at least one acre of forest
drop if forestAcres<1

**# Starting plotting
*intermediate data

replace iengaged = iengaged * 100
replace ienrolled = ienrolled * 100

// preserve
// collapse (mean) iengaged ienrolled 
// gen group = "Landowners"
// gen group_id = 0
// save "$temp/temp1.dta" , replace
// restore

preserve
collapse (max) iengaged ienrolled , by(owner_key)
collapse (mean) iengaged ienrolled 
gen group = "Landowners"
gen group_id = 0
save "$temp/temp1.dta" , replace
restore

preserve
collapse (mean) iengaged ienrolled [aw = forestAcres]
gen group = "Area"
gen group_id = 1
save "$temp/temp2.dta" , replace
restore

*plotting

/*Nov 4*/

use "$temp/temp1.dta" , clear 
append using "$temp/temp2.dta" 
set scheme s1mono
graph bar   (mean)  iengaged (mean)  ienrolled  ,   over(group , descending label(labsize(medium) ))  blabel(bar , format(%9.1f))  bar(1, fcolor(maroon) ) bar(2, fcolor(navy))  bargap(10) legend(order(  1 "Engaged" 2 "Enrolled" ) size(small) ring(0) pos(11) ) note("") ytitle("Percent of Likely Eligible Landowners/Area")


foreach fig_path in figure {
	
	 dis  "$`fig_path'/fig1_bar_plot_R1"
		
	graph export "$`fig_path'/fig1_bar_plot_R1.png", as(png) name("Graph") replace
	graph export "$`fig_path'/fig1_bar_plot_R1.pdf", as(pdf) name("Graph") replace

}

